Skip to content

Conversation

csviri
Copy link
Collaborator

@csviri csviri commented Aug 11, 2025

Adds option to trigger reconciliation on all events.

Signed-off-by: Attila Mészáros [email protected]

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 11, 2025
@csviri csviri linked an issue Aug 11, 2025 that may be closed by this pull request
@csviri csviri changed the title feat: all-event mode feat: all-event reconcile mode Aug 11, 2025
@csviri csviri changed the base branch from main to next August 11, 2025 10:35
@csviri csviri changed the title feat: all-event reconcile mode feat: reconcile-all-event mode Aug 11, 2025
@csviri
Copy link
Collaborator Author

csviri commented Aug 21, 2025

@metacosm @xstefank I will add a bunch of unit tests, and docs, but the core of it is ready. Pls take a look, thank you.

@csviri csviri requested review from metacosm and xstefank August 21, 2025 14:50
@csviri csviri changed the title feat: reconcile-all-event mode feat: allow to propagate all event to reconiler Sep 3, 2025
@csviri csviri changed the title feat: allow to propagate all event to reconiler feat: trigger reconciler on all event Sep 4, 2025
@csviri csviri changed the title feat: trigger reconciler on all event feat: triggering reconciler on all event Sep 4, 2025
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 11, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 16, 2025
@csviri csviri changed the title feat: triggering reconciler on all event feat: option to triggering reconciler on all events Sep 17, 2025
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
@csviri csviri marked this pull request as ready for review September 17, 2025 11:39
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 17, 2025
@csviri
Copy link
Collaborator Author

csviri commented Sep 17, 2025

@xstefank @metacosm This feature is ready now, please review it. Happy to give also a tour together in case that is needed. thank you

Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
@metacosm
Copy link
Collaborator

As mentioned in the issue, I'd rather see this supported via listeners than via yet another feature flag.

@csviri
Copy link
Collaborator Author

csviri commented Sep 17, 2025

As mentioned in the issue, I'd rather see this supported via listeners than via yet another feature flag.

The idea behind this is same as controllers work in go, having a separate listernet would not be an eleant solution, basically we just trigger reconiliation for all the events as in go is done by default. This way we don't need an another interface or any other construct.

@csviri
Copy link
Collaborator Author

csviri commented Sep 17, 2025

As mentioned in the issue, I'd rather see this supported via listeners than via yet another feature flag.

Also in the past on purpose reduced the number of those interaces, and I think that was the right choice. I'm not that happy about to much feature flags, but I see this the as the better option now, since it is closed to go; feature flags use can much easier see than a new interface. And note that this is nost just about the delete events, but all the events, for example when others have finalizers added to the custom resources, it is marked for deletion, but meanwhile updated (or just on the mar of deletion event) so acutally much harder to capture with an interface. I really think this is a better model just to have to trigger the reconciler on everthing than having separate methods.

@metacosm
Copy link
Collaborator

Following the go SDK should only been done where it makes sense. I don't think it's a particularly compelling argument for this particular design or the other flags that have been introduced lately.

@csviri
Copy link
Collaborator Author

csviri commented Sep 17, 2025

Following the go SDK should only been done where it makes sense. I don't think it's a particularly compelling argument for this particular design or the other flags that have been introduced lately.

That is just a side note regarding to go, I don't see how an interface is a good alterative for that, especailly that we tried to eliminate (and did) all the interfaces for v5. But the main issues I see that, it would be even hard to scope as an interface, how would you define that? which events would trigger that interface?

@csviri
Copy link
Collaborator Author

csviri commented Sep 17, 2025

other flags that have been introduced lately

What other flags you mean?

@csviri
Copy link
Collaborator Author

csviri commented Sep 19, 2025

@metacosm I was giving more thoughs about this, but basically came to the same conclusion, regarding feature flags / interfaces.
I completely agree that best would be to have those as less as possible. But since we tried to eliminate the interaces for v5 and moving most of it (except Cleaner what is justifiable) into the Reconciler interface as default method. Basically to have this mode it the only viable options is to have it as feature flag, since event it would be harder to define as an interface.

Basically this was to have all events trigger the reconiler functions gives a very good mental model, and a simplistic user interface, that "I get triggered an all events, and can check in what state the primary and secondary resources are and act upon that"

Pls review the PR in depth.

@csviri
Copy link
Collaborator Author

csviri commented Sep 19, 2025

other flags that have been introduced lately

For this pls create an issue where we can separately discuss your concerns in detail.

boolean isNextReconciliationImminent();

/**
* To check if the primary resource is already deleted. This value can be true only if you turn on
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be enforced in the code.

boolean isPrimaryResourceDeleted();

/**
* Check this only if {@link #isPrimaryResourceDeleted()} is true.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

public static <P extends HasMetadata> P conflictRetryingPatch(
KubernetesClient client,
P resource,
UnaryOperator<P> unaryOperator,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide proper javadoc for all public methods with appropriate parameter names (e.g. unaryOperator doesn't help understand what is the purpose of this parameter).

public void onDelete(T resource, boolean b) {
super.onDelete(resource, b);
eventReceived(ResourceAction.DELETED, resource, null);
eventReceived(ResourceAction.DELETED, resource, null, b);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a proper parameter name instead of b.

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.javaoperatorsdk.operator.processing.event.ResourceID;

public class ResourceDeleteEvent extends ResourceEvent {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add documentation.


private void handleMarkedEventForResource(ResourceState state) {
if (state.deleteEventPresent()) {
if (state.deleteEventPresent() && !triggerOnAllEvent()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract in a separate method, that can be reused elsewhere.

log.debug(
"Resource not found in the cache, checking for delete event resource: {}",
resourceID);
var state = resourceStateManager.get(resourceID);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only be done / needed if this is a delete event so the state retrieval should only be done in that case.

.filter(ResourceState::deleteEventPresent)
.map(ResourceState::getLastKnownResource);
if (actualResource.isEmpty()) {
throw new IllegalStateException("this should not happen");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a proper message here instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to trigger reconciler on all event
3 participants